package com.cskaoyan.controller.backstagecontroller;


import com.cskaoyan.bean.vo.BaseRespVo;
import com.fasterxml.jackson.databind.exc.InvalidFormatException;

import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @description: 处理resquestbody数据异常
 * @author: ywp
 * @creatTime: 2021年07月02日
 */
@ControllerAdvice
public class ExceptionControllerAdvice {

//    @ExceptionHandler(AuthorizationException.class)
//    @ResponseBody
//    public BaseRespVo handlerAuthorException(Exception e) {
//        return BaseRespVo.fail("你没有此操作的权限！请联系管理员");
//    }

    //TODO: 处理异常


//    @ExceptionHandler(UsernameDuplicatedException.class)
//    @ResponseBody
//    public BaseRespVo usernameDuplicatedException(Exception e) {
//        return BaseRespVo.fail(e.getMessage());
//    }

    @ExceptionHandler(InvalidFormatException.class)
    @ResponseBody
    public BaseRespVo invalidFormatException(Exception e){return BaseRespVo.fail("参数类型错误");}
}